import msnp
import threading

class MsnListener(msnp.SessionCallbacks):
    def state_changed(self, state):
        if state == msnp.States.ONLINE:
            print 'You are now online.'
    def chat_started(self, chat):
        callbacks = MsnChatListener()
        chat.callbacks = callbacks
        callbacks.chat = chat

class MsnChatListener(msnp.ChatCallbacks):
    def message_received(self, passport_id, display_name, text, charset):
	global daft
        print '%s: %s' % (passport_id, text)
        self.chat.send_message(daft.boom(text), charset)

def tick(daft):
	pass

class msnthread ( threading.Thread ):
	def run ( self , daft):
		msn = msnp.Session()
		msn.login('dobbybot@gmail.com', 'lovesocks')
		while True:
			msn.process()
			daft.tick()
